package com.we823.cms.model.cms;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.we823.cms.model.BaseModelWithDate;

@Entity
@Table(name="cms_channel")
public class Channel extends BaseModelWithDate<Integer> {

	private static final long serialVersionUID = -1401242044791485344L;
	
	private String name;
	
	@Transient
	private Channel parent;
	@Column(name = "parent_id")
	private Integer parentId;
	
	private Integer type=0;
	private String linkurl;
	private String summary;
	private String content;
	private Integer orderid=1;
	
	@Column(name="template_id")
	private Integer templateId=0;
	
	private Integer inmenu=1;
	private Integer isopen=1;
	private Integer hits=1;
	
	@Transient
	private List<Channel> childs=new ArrayList<>();
	
	@Transient
	private boolean hasChildren = false;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public String getLinkurl() {
		return linkurl;
	}
	public void setLinkurl(String linkurl) {
		this.linkurl = linkurl;
	}
	public String getSummary() {
		return summary;
	}
	public void setSummary(String summary) {
		this.summary = summary;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public Integer getOrderid() {
		return orderid;
	}
	public void setOrderid(Integer orderid) {
		this.orderid = orderid;
	}
	public Integer getTemplateId() {
		return templateId;
	}
	public void setTemplateId(Integer templateId) {
		this.templateId = templateId;
	}
	public Integer getInmenu() {
		return inmenu;
	}
	public void setInmenu(Integer inmenu) {
		this.inmenu = inmenu;
	}
	public Integer getIsopen() {
		return isopen;
	}
	public void setIsopen(Integer isopen) {
		this.isopen = isopen;
	}
	public Integer getHits() {
		return hits;
	}
	public void setHits(Integer hits) {
		this.hits = hits;
	}
	public Channel getParent() {
		return parent;
	}
	public void setParent(Channel parent) {
		this.parent = parent;
	}
	public List<Channel> getChilds() {
		return childs;
	}
	public void setChilds(List<Channel> childs) {
		this.childs = childs;
	}
	public boolean getHasChildren() {
		if(childs!=null && childs.size()>0){
			return true;
		}
		return hasChildren;
	}
	public void setHasChildren(boolean hasChildren) {
		this.hasChildren = hasChildren;
	}


	public Integer getParentId() {
		return parentId;
	}

	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}
}
